package com.ry.core.exception;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.concurrent.atomic.AtomicLong;

/**
 * 异常基类
 * @author chengl
 * @Date 2011-8-17
 * @version	1.0
 */
public abstract class BaseException extends Exception {

	private static final long serialVersionUID = -4305232971206313027L;
	
	private static AtomicLong atomicLong = new AtomicLong(System.currentTimeMillis());
    private String id;

    public BaseException() {
        super();
        setId();
    }

    public BaseException(final String message) {
        super(message);
        setId();
    }

    public BaseException(final String message,final Throwable cause) {
        super(message, cause);
        setId();
    }

   private void setId() {
        long nid = atomicLong.incrementAndGet();
        id = Long.toString(nid,26);
    }

    public abstract String getErrorTitle();

    public abstract String getErrorDescription();

    

    public Integer getLineNumber() {
        return -1;
    }
    public String getId() {
        return id;
    }
    
    public static String toString(Exception e){
    	StringWriter sw = new StringWriter(); 
		PrintWriter pw = new PrintWriter(sw); 
		e.printStackTrace(pw); 
    	return sw.toString();
    }

}